import React, { useState, useRef, useEffect } from 'react'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table'
import { Link, connect } from 'umi'
import { queryArchiveStaffList } from '../../service'
import { Tooltip } from 'antd'
import { isOfferList, isSubmitList, socialTraineeStateArray } from '@/utils/constant'

const TableList = () => {
  const actionRef = useRef()
  const columns = [
    {
      title: '编号',
      dataIndex: 'employeeOid',
      hideInSearch: true
    },
    {
      title: '姓名',
      dataIndex: 'name',
      render: (item, record) => (
        <Link to={`/info/details/${record.oid}`}>{item}</Link>
      ),
    },
    {
      title: '公司',
      dataIndex: 'orgname',
    },
    {
      title: '部门',
      dataIndex: 'unitname',
    },
    {
      title: '岗位',
      dataIndex: 'jobname',
    },
    {
      title: '职级',
      dataIndex: 'jobLevel',
      hideInSearch: true,
    },
    {
      title: 'Offer发送',
      dataIndex: 'isOffer',
      hideInSearch: true,
      valueEnum: {
        0: { text: isOfferList[0].label, status: 'Default' },
        1: { text: isOfferList[1].label, status: 'Success' },
      },
    },
    {
      title: '信息采集',
      dataIndex: 'isMemberDone',
      hideInSearch: true,
      valueEnum: {
        0: { text: isSubmitList[0].label, status: 'Default' },
        1: { text: isSubmitList[1].label, status: 'Success' },
      },
    },
    {
      title: '录用状态',
      dataIndex: 'status',
      hideInSearch: true,
      valueEnum: {
        0: { text: '待发起', status: 'Default' },
        1: { text: '填写完以保存', status: 'Default' },
        2: { text: '审批中', status: 'Processing' },
        3: { text: '已审批', status: 'Success' },
        4: { text: '流程作废', status: 'Default' },
        5: { text: 'Offer已发送', status: 'Success' },
        6: { text: '流程被驳回', status: 'Default' },
      },
    },
    {
      title: '是否入职',
      dataIndex: 'isHireDone',
      hideInSearch: true,
      render: () => {
        return "入职终止"
      }
    },
    {
      title: '招聘类型',
      dataIndex: 'socialTrainee',
      valueEnum: {
        0: { text: socialTraineeStateArray[0] },
        1: { text: socialTraineeStateArray[1] },
      },
    },
    {
      title: '归档原因',
      dataIndex: 'endRemark',
      hideInSearch: true,
      onCell: ()=>{
        return {
          style:{
            maxWidth:200,
            overflow:'hidden',
            whiteSpace:'nowrap',
            textOverflow:'ellipsis',
            cursor:'pointer',
          }
        }
      },
      render: (text) =>{
        return <Tooltip placement="topLeft" title={text}>{text}</Tooltip>
      }
    }
  ]

  return (
    <PageHeaderWrapper>
        <ProTable
          actionRef={actionRef}
          rowKey="employeeOid"
          request={(params) => queryArchiveStaffList(params)}
          columns={columns}
        />
    </PageHeaderWrapper>
  )
}

export default connect(() => ({
}))(TableList)
